;ASCII码转十六进制

data segment
    xx db ?
    ascii db 'a'
data ends

code segment
    assume cs:code,ds:data
start:
    mov ax,data
    mov ds,ax

    mov al,ascii
    cmp al,'0'

lab: jb lab5
    mov ah,al
    sub ah,'0'
    
    cmp al,'9'
    jbe lab6

    cmp al,'A'
    jb lab5

    mov ah,al
    sub ah,'A'-10

    cmp al,'F'
    jbe lab6

    cmp al,'a'
    jb lab5

    mov ah,al
    sub al,'a'-10
    cmp al,'f'
    jbe lab6

lab5: mov ah,-1
lab6: mov xx,ah

    mov ah,4ch
    int 21h
code ends

end start